<template>
	<div class="loginContent">
		
		<div class="formBody">
			
			<el-form :model="formLogin" >
			    <el-form-item>
			        <h2 class="title">文章发布后台管理系统</h2>
			    </el-form-item>
			    <el-form-item>
			        <el-input v-model="formLogin.UserName" placeholder="账号"></el-input>
			    </el-form-item>
			    <el-form-item>
			        <el-input type="password" v-model="formLogin.Password" placeholder="密码"></el-input>
			    </el-form-item>
			    <el-form-item>
			        <el-button type="primary" @click="handleLogin">登陆</el-button>
					<el-button style="primary" @click="handeLoginWX()">微信登录</el-button>
			        <span v-show="this.errorInfo.isShowError" class='error'>
			            {{this.errorInfo.text}}
			        </span>
			    </el-form-item>
				</el-form>
		</div>
		<div v-html="wxCode"></div>
		
	</div>
</template>

<script>
import request from './utils/request.js'
export default{
	name:'Login',
	data(){
		return{
			
			wxCode:'',
			id:3,
			formLogin: {
				//表单对象
				UserName: 'admin',
				Password: 'admin'
			},
			apiUrl:process.env.VUE_APP_BASE_ELM_API,
			errorInfo: {
			    text: '登陆失败,请重试',
			    isShowError: false //显示错误提示
			}
		}
	},
	methods:{
		handleLogin()
		{
			/*sessionStorage.setItem('sysuser',JSON.stringify(this.formLogin)) 
			var that =this;
          var UserName = that.formLogin.UserName;
          var Password = that.formLogin.Password;
			request({
				//url: that.apiUrl + '/Common/CheckLoginSysUser',
				url:'/api/admin/login',
				 method: 'post',
				data:{UserName, Password}
			}).then(function(response) {

				console.log(response);
			});*/
			 this.$router.push({path:'/mycenter'})
		},
		handeLoginWX()
		{
			var that =this;
			var redURL=encodeURIComponent('http://192.168.0.109:8090/Login');
			request({
				//url:'/wx/connect/qrconnect?appid=wxd5df730d9983629a&redirect_uri='+encodeURIComponent('http://192.168.0.109:8090')+'&response_type=code&scope=snsapi_base',
				url:'/wx/connect/oauth2/authorize?appid=wxd5df730d9983629a&redirect_uri='+redURL+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect',
				method:'get'
				/*data:{
					appid:'wx05afc11cd841a5a8',
					redirect_uri:encodeURIComponent('http://localhost:8090'),
					response_type:'code',
					scope:'snsapi_logi'
					
				}*/
			}).then(function(response){
				that.wxCode=response.data;
				console.log(response);
			});
		}
		
	}
}
</script>

<style scoped="scoped" >
	
	.loginContent
	{
		background-image: url("assets/imgs/bg.jpg");
		background-repeat:no-repeat;
		background-size: cover;
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		
		
	}
	 .formBody{
		margin: auto;
		width: 460px;
		height: 296px;
		background: #FFF;
		
		border: 1px solid #eaeaea;
		box-shadow: 0 0 25px #cac6c6;
		
	}
	.formBody .title{
		text-align: center;
		color: #505458;
		margin-top: 10px;
	}
	.el-form {
	    margin: 30px 80px auto 80px;
	   
	}

</style>
